const http = require('http')
const server = http.createServer()
server.on('request',(req,res)=>{
    // req.url是客户端的请求url地址
    const url = req.url
    // req.method是客户端的method类型
    const method=req.method
    const str = `请求的地址是 ${url},请求的method类型 ${method}`
    console.log(str);
    // 解决发送客户端中文乱码的问题 设置Content-Type响应头 
    res.setHeader('Content-Type','text/html;charset=utf-8')
    res.end(str)

})
server.listen(8080,()=>{
    console.log('server runing at http://127.0.0.1');
})